﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace test9
{
    class Person
    {
        public Person(int age = 20, string name ="张三", string adder = "地球")
        {
            this._age = age;
            this._name = name;
            this._adder = adder;
        }

        virtual public void print()
        {
            Console.WriteLine("姓名:" + _name);
            Console.WriteLine("年龄: " + _age);
            Console.WriteLine("地址" + _adder);
        }

        protected int _age;
        protected string _name;
        protected string _adder;
    }

    class Student : Person
    {

        public Student(string stuId = "0123456789",int age = 20, string name ="张三", string adder = "地球" ) 
        {
            this._age = age;
            this._name = name;
            this._stuId = stuId;
            this._adder = adder;
        }
        public void AttendClass()
        {
            Console.WriteLine("上课——听课");
        } 

        public void Exam()
        {
            Console.WriteLine("考试——答题");
        }

        override public void print()
        {
            Console.WriteLine("姓名:" + _name);
            Console.WriteLine("年龄: " + _age);
            Console.WriteLine("地址: " + _adder);
            Console.WriteLine("学号: " + _stuId);
        }

        protected string _stuId;
    }

    class Teacher : Person
    {
        public Teacher(string title = "教授",int age = 20, string name ="张三", string adder = "地球" ) 
        {
            this._age = age;
            this._name = name;
            this._title = title;
            this._adder = adder;
        }

        public void AttendClass()
        {
            Console.WriteLine("上课——讲课");
        }

        public void Exam()
        {
            Console.WriteLine("考试——监考");
        }

        override public void print()
        {
            Console.WriteLine("姓名:" + _name);
            Console.WriteLine("年龄: " + _age);
            Console.WriteLine("地址: " + _adder);
            Console.WriteLine("职称: " + _title);
        }

        protected string _title;
    }
    class MyEvent
    {
        public event EventHandler<Student> OnInput; //定义一个委托类型的事件  
        public void WaitInput()
        {
                string str = Console.ReadLine();
                if(str == "class")
                { 
                    OnInput(this, new Student("123", 21, "李四", "地球")); //触发事件
                }
                else
                {
                    Console.WriteLine("非法输入");
                }
        }
    }


    class Program
    {
        static void test()
        {
            Student st = new Student("123", 21, "李四", "地球");
            st.print();
            st.AttendClass();
            st.Exam();

            Teacher te = new Teacher("副教授", 50, "张三", "火星");
            te.print();
            te.AttendClass();
            te.Exam();
        }
        static void Main(string[] args)
        {
            //MyEvent Evt = new MyEvent();//实例化
            //Evt.OnInput += On_Input;
            //Evt.WaitInput();
            test();
        }

        private static void On_Input(object sender, Student e)
        {
            e.AttendClass();
        }

    }
}
